﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NetChatInterface
{
    public partial class SetForm : Form
    {
        public SetForm()
        {
            InitializeComponent();
        }
        //************************************************************************
        //声明变量
        public static bool afterset = false;
        public static Image MyHeadImage;
        public static Color FormBackColor;
        //************************************************************************

        private void SetMyHeadbutton_Click(object sender, EventArgs e)
        {
            //********************************************************************
            //设置用户头像
            SetHeadopenFileDialog.Filter = "Image Files(*.bmp;*.wmf;*.ico;*.cur;*.jgp)|*.bmp;*.wmf;*.ico;*.cur;*.jpg";
            if (SetHeadopenFileDialog.ShowDialog() == DialogResult.OK)
            {
                MyHeadpanel.BackgroundImage = Image.FromFile(SetHeadopenFileDialog.FileName);
                MyHeadImage = Image.FromFile(SetHeadopenFileDialog.FileName);
            }
            //********************************************************************
        }

        private void SetSkinColorbutton_Click(object sender, EventArgs e)
        {
            //********************************************************************
            //调整皮肤颜色
            if (SetcolorDialog.ShowDialog() == DialogResult.OK)
            {
                FormBackColor = SetcolorDialog.Color;
                this.BackColor = FormBackColor;
            }
            //********************************************************************
        }

        private void ReSetbutton_Click(object sender, EventArgs e)
        {
            //********************************************************************
            //皮肤头像还原
            MyHeadImage = global::NetChatInterface.Properties.Resources.大头像;            
            MyHeadpanel.BackgroundImage = global::NetChatInterface.Properties.Resources.大头像;
            FormBackColor = SystemColors.InactiveCaptionText;
            this.BackColor = SystemColors.InactiveCaptionText;
            //********************************************************************
        }

        private void OK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;//关闭窗口，保存更改
        }

        private void SetForm_VisibleChange(object sender, EventArgs e)
        {
            //***************************************************************
            //如果是第一次设置，现将变量初始化
            if (afterset == false)
            {
                MyHeadImage = global::NetChatInterface.Properties.Resources.大头像;
                FormBackColor = SystemColors.InactiveCaptionText;
                afterset = true;
            }
            //***************************************************************
        }

    }
}
